Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented the behavioral design pattern 'State' contained in new file created named 'webscraper_state_pattern.py'. This pattern integrates with the file 'webscraper.py' for the methods connect() and save_to_db() because these methods follow a specific order.
Since these 2 methods are sequential, i.e. the method connect() must be called before the method save_to_db(), the state pattern can instead assign states of the program that tells you the current state whether it is in state where connect() must be called (ConcreteConnectState()) or in the state where save_to_db() bust be called (ConcreteSaveState()).
This improves the system design by removing redundancies in the method implementations as well creating an abstraction for the method implementations which makes the code less complex. Another benefit of this design is that this pattern can now also be used by other files in the code base that deals with methods connect() and / or save_to_db() such as the file 'db_connector.py' in the same directory.
This design also emphasizes using the state transitions that create a sequence such that when the program is at a certain state, the program can only execute specific methods that adhere to the corresponding state. This makes the structure of the code much cleaner and more efficient both in space as well as time.